﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Measure.aspx.cs" Inherits="SalesManagement.Modules.List.Measure" %>

<%@ Register Src="~/Controls/List/MeasureForm.ascx" TagName="WindowEditor" TagPrefix="uc" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Quy đổi đơn vị</title>

    <script language="javascript" type="text/javascript">
        function DocumentReady() {
            MethodNamespace.DocumentReady({

        });
    }
       
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="MethodNamespace">
        <Listeners>
            <DocumentReady Handler="DocumentReady();" Delay="100" />
        </Listeners>
    </ext:ResourceManager>
    <ext:Store ID="stProduct" runat="server" AutoLoad="false">
        <Reader>
            <ext:JsonReader IDProperty="ProductId">
                <Fields>
                    <ext:RecordField Name="ProductId" />
                    <ext:RecordField Name="ProductName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="storeMeasure" runat="server" AutoLoad="false" OnRefreshData="storeMeasure_OnRefreshData">
        <Reader>
            <ext:JsonReader>
                <Fields>
                    <ext:RecordField Name="ProductId" />
                    <ext:RecordField Name="ProductName" />
                    <ext:RecordField Name="Ratio" />
                    <ext:RecordField Name="BasicUnit" />
                    <ext:RecordField Name="RatioUnit" />
                    <ext:RecordField Name="BasicName" />
                    <ext:RecordField Name="RatioName" />
                    <ext:RecordField Name="IsActive" />
                    <ext:RecordField Name="Deleted" />
                    <ext:RecordField Name="CreatedDate" />
                    <ext:RecordField Name="CreatedBy" />
                    <ext:RecordField Name="UpdatedDate" />
                    <ext:RecordField Name="UpdatedBy" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="Viewport1" runat="server" Layout="RowLayout">
        <Items>
            <ext:GridPanel ID="grdMeasure" runat="server" AutoExpandColumn="Ratio" RowHeight="1"
                TrackMouseOver="true" Border="false" StoreID="storeMeasure">
                <TopBar>
                    <ext:Toolbar ID="tbMain" runat="server">
                        <Items>
                            <ext:ComboBox ID="cboProduct" runat="server" FieldLabel="Tên hàng" DataIndex="Title"
                                Flex="6" StoreID="stProduct" DisplayField="ProductName" ValueField="ProductId"
                                Editable="true" TypeAhead="true" LoadingText="Tìm kiếm..." TriggerAction="All"
                                MinChars="1" LabelWidth="80" Width="350">
                                <Listeners>
                                    <Select Handler="storeMeasure.reload();" />
                                </Listeners>
                            </ext:ComboBox>
                            <ext:ToolbarFill />
                            <ext:ToolbarSpacer />
                            <ext:Button ID="btnAdd" runat="server" Text="Thêm mới" Icon="TableRelationship">
                                <DirectEvents>
                                    <Click OnEvent="btnAdd_Click" />
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ColumnID="ProductName" DataIndex="ProductName" Header="Tên hàng" />
                        <ext:Column ColumnID="BasicName" DataIndex="BasicName" Header="Đơn vị gốc" />
                        <ext:Column ColumnID="RatioName" DataIndex="RatioName" Header="Đơn vị quy đổi" />
                        <ext:Column ColumnID="Ratio" DataIndex="Ratio" Header="Tỷ lệ" />
                        <ext:CommandColumn Width="80" Align="Center">
                                        <Commands>
                                            <ext:GridCommand Icon="NoteEdit" CommandName="Edit" Text="Cập nhật">
                                            </ext:GridCommand>
                                        </Commands>
                                    </ext:CommandColumn>
                                    <ext:CommandColumn Width="60" ButtonAlign="Center">
                                        <Commands>
                                            <ext:GridCommand Icon="NoteDelete" CommandName="Delete" Text="Xóa">
                                            </ext:GridCommand>
                                        </Commands>
                                    </ext:CommandColumn>
                                </Columns>
                            </ColumnModel>
                            <DirectEvents>
                                <Command OnEvent="grdMeasure_OnCommand">
                                    <ExtraParams>
                                        <ext:Parameter Name="command" Value="command" Mode="Raw" />
                                        <ext:Parameter Name="ProductId" Value="record.data.ProductId" Mode="Raw" />
                                        <ext:Parameter Name="BasicUnit" Value="record.data.BasicUnit" Mode="Raw" />
                                        <ext:Parameter Name="RatioUnit" Value="record.data.RatioUnit" Mode="Raw" />
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true" Message="Bạn có thật sự muốn xóa dòng dữ liệu này không?"
                                        Title="Thông báo" BeforeConfirm="if (command=='Edit') return false;" />
                                </Command>
                            </DirectEvents>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                </SelectionModel>
                <BottomBar>
                    <ext:PagingToolbar ID="paddingBar" StoreID="storeMeasure" runat="server" PageSize="50"
                        DisplayInfo="true" DisplayMsg="Đang xem dòng {0} đến {1} của {2}" EmptyMsg="Không có dữ liệu">
                    </ext:PagingToolbar>
                </BottomBar>
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    <uc:WindowEditor ID="WindowEditor" runat="server" />
    </form>
</body>
</html>
